﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework;

namespace ERF.Input
{
    /// <summary>
    /// Represents a button on a mouse.
    /// </summary>
    public class AssignedMouseButton : AssignedButton
    {
        /// <summary>
        /// They apparently decided to handle every single control device in a different way, 
        /// so we need to do this enum ourselves.
        /// </summary>
        public enum Buttons
        {
            LEFT,
            RIGHT
        }
        private Buttons mouseButton;

        public AssignedMouseButton(InputHandler handler, Buttons mouseButton)
            : base(handler)
        {
            this.mouseButton = mouseButton;
        }

        /// <summary>
        /// Returns a boolean denoting if the mousebutton is currently being pressed or not.
        /// </summary>
        /// <returns></returns>
        public override bool IsButtonDown()
        {
            if ((Buttons)mouseButton == Buttons.LEFT)
                return (handler.MouseState.LeftButton == ButtonState.Pressed);

            if ((Buttons)mouseButton == Buttons.RIGHT)
                return (handler.MouseState.RightButton == ButtonState.Pressed);

            return false;
        }

        /// <summary>
        /// Returns a boolean denoting if the mousebutton has just been released.
        /// </summary>
        /// <returns></returns>
        public override bool IsButtonReleased()
        {
            if (mouseButton == Buttons.LEFT)
                return (handler.MouseState.LeftButton == ButtonState.Pressed);

            if (mouseButton == Buttons.RIGHT)
                return (handler.MouseState.RightButton == ButtonState.Pressed);

            return false;
        }
    }
}
